﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace STMS.WSTMSystem.UControls
{
    public partial class UCircle : UserControl
    {
        public UCircle()
        {
            InitializeComponent();
        }

        private int borderWidth = 0;
        public int BorderWidth
        {
            get { return this.borderWidth; }
            set
            {
                borderWidth = value;
                Refresh();
            }
        }

        private Color borderColor = Color.Gray;
        public Color BorderColor
        {
            get { return this.borderColor; }
            set
            {
                borderColor = value;
                Refresh();
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rect = e.ClipRectangle;

            if(borderWidth>0)
            {
                g.DrawEllipse(new Pen(this.BorderColor, this.BorderWidth), rect);
                Rectangle rect1 = new Rectangle(rect.Left + BorderWidth, rect.Top + BorderWidth, rect.Width - 2 * BorderWidth, rect.Height - 2 * BorderWidth);
                g.FillEllipse(new SolidBrush(this.ForeColor), rect1);
            }
            else
            {
                Rectangle rect1 = new Rectangle(rect.Left+1, rect.Top+1, rect.Width-2, rect.Height-2);
                g.DrawEllipse(new Pen(this.BorderColor, this.BorderWidth),rect1);
              
                g.FillEllipse(new SolidBrush(this.ForeColor), rect1);
            }
           
        }
    }
}
